<!--
 * @Author: your name
 * @Date: 2020-02-28 10:34:40
 * @LastEditTime: 2020-02-28 11:13:44
 * @LastEditors: Please set LastEditors
 * @Description: 报表导出
 * @FilePath: /dypc/src/views/exportFile/index.vue
 -->
<template>
  <div class="export-file">
    <div class="file-row">
      <span>全市网格检查总体情况表：</span>
      <el-date-picker
        v-model="value1"
        type="datetimerange"
        format="yyyy-MM-dd HH:mm:ss"
        value-format="yyyy-MM-dd HH:mm:ss"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
      <el-button type="primary" @click="download1">导出</el-button>
    </div>
    <div class="file-row">
      <span>全市巡查问题清单表：</span>
      <el-date-picker
        v-model="value2"
        type="datetimerange"
        format="yyyy-MM-dd HH:mm:ss"
        value-format="yyyy-MM-dd HH:mm:ss"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
      <el-button type="primary" @click="download2">导出</el-button>
    </div>
    <div class="file-row">
      <span>东阳市网格工作组成员情况汇总表：</span>
      <el-date-picker
        v-model="value3"
        type="datetimerange"
        format="yyyy-MM-dd HH:mm:ss"
        value-format="yyyy-MM-dd HH:mm:ss"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
      <el-button type="primary" @click="download3">导出</el-button>
    </div>
    <div class="file-row">
      <span>东阳市网格工作组成员巡查汇总表：</span>
      <el-date-picker
        v-model="value4"
        type="datetimerange"
        format="yyyy-MM-dd HH:mm:ss"
        value-format="yyyy-MM-dd HH:mm:ss"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
      <el-button type="primary" @click="download4">导出</el-button>
    </div>
  </div>
</template>
<script>
import { parseTime } from '@/utils'
import { exportFile } from '@/utils/index'
export default {
  data() {
    const date1 = parseTime(new Date()).slice(0, 10)
    return {
      value1: ['2020-2-24 15:00:00', date1 + ' ' + '15:00:00'],
      value2: ['2020-2-24 15:00:00', date1 + ' ' + '15:00:00'],
      value3: ['2020-2-24 15:00:00', date1 + ' ' + '15:00:00'],
      value4: ['2020-2-24 15:00:00', date1 + ' ' + '15:00:00']
    }
  },
  created() {
    // const date1 = parseTime(new Date()).slice(0, 10)
    // this.value1 = ['2020-2-24 15:00:00', date1 + ' ' + '15:00:00']
    // this.value1 = [new Date(2020, 1, 24, 15, 0), new Date(date1[0], date1[1] - 1, date1[2], 15, 0, 0)]
  },
  methods: {
    // 全市网格检查总体情况表
    download1() {
      exportFile('v1/manage/sars/info/download/1', {
        start_at: this.value1[0],
        end_at: this.value1[1]
      })
    },
    // 全市巡查问题清单表
    download2() {
      exportFile('v1/manage/sars/info/download/2', {
        start_at: this.value2[0],
        end_at: this.value2[1]
      })
    },
    // 东阳市网格工作组成员情况汇总表
    download3() {
      exportFile('v1/manage/sars/info/download/3', {
        start_at: this.value3[0],
        end_at: this.value3[1]
      })
    },
    download4() {
      exportFile('v1/manage/sars/info/download/4', {
        start_at: this.value4[0],
        end_at: this.value4[1]
      })
    }
  }
}
</script>
<style lang="scss">
.export-file {
  padding: 20px 40px;
  .el-button {
    margin-left: 20px;
  }
  .file-row {
    margin-top: 30px;
  }
}
</style>
